<template>
  <div class="systemConfig">
    <el-form
      ref="baseFormRef"
      :model="baseForm"
      :rules="rules"
      label-width="140px"
    >
      <el-row :gutter="20" style="margin-top: 15px">
        <el-col :span="12">
          <el-form-item label="超级管理员">
            <user-select
              v-model="adminIds"
              placeholder="请选择超级管理员"
              multiple
            />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item>
            <el-button
              type="primary"
              size="small"
              class="saveBtn"
              :loading="btnLoading"
              @click="submitSaveAdminList('UserConfig')"
              >保 存</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { getAdminList, setAdminList } from "@/api/system/sysConfig";
export default {
  name: "SysConfigAdministratorSetting",
  props: {},
  data() {
    return {
      btnLoading: false,
      adminIds: [],
      baseForm: {},
      rules: {},
    };
  },
  watch: {},
  computed: {
    UserConfig() {
      return {
        category: "UserConfig",
        list: [
          {
            name: "超级管理员",
            key: "adminIds",
            value: this.baseForm.adminIds,
          },
        ],
      };
    },
  },
  methods: {
    /**查询系统管理员列表 */
    queryDataAdminList() {
      getAdminList().then((res) => {
        if (!res.data) return;
        this.adminIds = res.data.map((o) => o.id);
      });
    },
    /**保存 */
    submitSaveAdminList() {
      this.btnLoading = true;
      setAdminList(this.adminIds).then((res) => {
        this.$message({
          message: res.msg,
          type: "success",
          duration: 1500,
          onClose: () => {
            this.btnLoading = false;
          },
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.systemConfig {
  padding: 0;

  .saveBtn {
    width: 100px;
  }
}
</style>